package gac.helloworld;

import java.util.ArrayList;

import android.app.Activity;
import android.util.Log;
import android.widget.ArrayAdapter;

public class PlacesAdapter<Object> extends ArrayAdapter<String> {
	  private ArrayList<String> mObjects;
	  
	  public PlacesAdapter(Activity a){
		  super(a, R.layout.list_item);
		  this.setNotifyOnChange(true);
		  mObjects = new ArrayList<String>();
	  }

	@Override
	public int getCount() {
	return mObjects.size();
	}

	@Override
	public String getItem(int position) {
	return mObjects.get(position);
	}

	@Override
	public int getPosition(String item) {
	return mObjects.indexOf(item);
	}
	
	public void changeItems(ArrayList<String> newItems){
		mObjects.clear();
		for(String s : newItems){
			mObjects.add(s);
		}
		this.notifyDataSetChanged();
	}
	
	public void logItems(){
		String result = "";
		for(String object : mObjects){
			result += object +"\n";
		}
		Log.v("","LOGGING ITEMS");
		Log.v("",result);
	}

	}